using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace SurveyHost.Core.DAL{
    /// <summary>
    /// Strongly-typed collection for the QuestionDefinition class.
    /// </summary>
    [Serializable]
    public partial class QuestionDefinitionCollection : ReadOnlyList<QuestionDefinition, QuestionDefinitionCollection>
    {        
        public QuestionDefinitionCollection() {}

    }

    /// <summary>
    /// This is  Read-only wrapper class for the QuestionDefinition view.
    /// </summary>
    [Serializable]
    public partial class QuestionDefinition : ReadOnlyRecord<QuestionDefinition> 
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }

	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }

                return BaseSchema;
            }

        }

    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("QuestionDefinition", TableType.View, DataService.GetInstance("SurveyHost"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = "dbo";
                //columns
                
                TableSchema.TableColumn colvarStemId = new TableSchema.TableColumn(schema);
                colvarStemId.ColumnName = "StemId";
                colvarStemId.DataType = DbType.Guid;
                colvarStemId.MaxLength = 0;
                colvarStemId.AutoIncrement = false;
                colvarStemId.IsNullable = false;
                colvarStemId.IsPrimaryKey = false;
                colvarStemId.IsForeignKey = false;
                colvarStemId.IsReadOnly = false;
                
                schema.Columns.Add(colvarStemId);
                
                TableSchema.TableColumn colvarMeasureName = new TableSchema.TableColumn(schema);
                colvarMeasureName.ColumnName = "MeasureName";
                colvarMeasureName.DataType = DbType.String;
                colvarMeasureName.MaxLength = 100;
                colvarMeasureName.AutoIncrement = false;
                colvarMeasureName.IsNullable = true;
                colvarMeasureName.IsPrimaryKey = false;
                colvarMeasureName.IsForeignKey = false;
                colvarMeasureName.IsReadOnly = false;
                
                schema.Columns.Add(colvarMeasureName);
                
                TableSchema.TableColumn colvarMeasureRank = new TableSchema.TableColumn(schema);
                colvarMeasureRank.ColumnName = "MeasureRank";
                colvarMeasureRank.DataType = DbType.Int32;
                colvarMeasureRank.MaxLength = 0;
                colvarMeasureRank.AutoIncrement = false;
                colvarMeasureRank.IsNullable = true;
                colvarMeasureRank.IsPrimaryKey = false;
                colvarMeasureRank.IsForeignKey = false;
                colvarMeasureRank.IsReadOnly = false;
                
                schema.Columns.Add(colvarMeasureRank);
                
                TableSchema.TableColumn colvarQuestionText = new TableSchema.TableColumn(schema);
                colvarQuestionText.ColumnName = "QuestionText";
                colvarQuestionText.DataType = DbType.String;
                colvarQuestionText.MaxLength = 1000;
                colvarQuestionText.AutoIncrement = false;
                colvarQuestionText.IsNullable = false;
                colvarQuestionText.IsPrimaryKey = false;
                colvarQuestionText.IsForeignKey = false;
                colvarQuestionText.IsReadOnly = false;
                
                schema.Columns.Add(colvarQuestionText);
                
                TableSchema.TableColumn colvarStemRank = new TableSchema.TableColumn(schema);
                colvarStemRank.ColumnName = "StemRank";
                colvarStemRank.DataType = DbType.Int32;
                colvarStemRank.MaxLength = 0;
                colvarStemRank.AutoIncrement = false;
                colvarStemRank.IsNullable = false;
                colvarStemRank.IsPrimaryKey = false;
                colvarStemRank.IsForeignKey = false;
                colvarStemRank.IsReadOnly = false;
                
                schema.Columns.Add(colvarStemRank);
                
                TableSchema.TableColumn colvarAnswerType = new TableSchema.TableColumn(schema);
                colvarAnswerType.ColumnName = "AnswerType";
                colvarAnswerType.DataType = DbType.String;
                colvarAnswerType.MaxLength = 250;
                colvarAnswerType.AutoIncrement = false;
                colvarAnswerType.IsNullable = true;
                colvarAnswerType.IsPrimaryKey = false;
                colvarAnswerType.IsForeignKey = false;
                colvarAnswerType.IsReadOnly = false;
                
                schema.Columns.Add(colvarAnswerType);
                
                TableSchema.TableColumn colvarAnswerTypeConfiguration = new TableSchema.TableColumn(schema);
                colvarAnswerTypeConfiguration.ColumnName = "AnswerTypeConfiguration";
                colvarAnswerTypeConfiguration.DataType = DbType.String;
                colvarAnswerTypeConfiguration.MaxLength = 500;
                colvarAnswerTypeConfiguration.AutoIncrement = false;
                colvarAnswerTypeConfiguration.IsNullable = true;
                colvarAnswerTypeConfiguration.IsPrimaryKey = false;
                colvarAnswerTypeConfiguration.IsForeignKey = false;
                colvarAnswerTypeConfiguration.IsReadOnly = false;
                
                schema.Columns.Add(colvarAnswerTypeConfiguration);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["SurveyHost"].AddSchema("QuestionDefinition",schema);
            }

        }

        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }

	    #endregion
	    
	    #region .ctors
	    public QuestionDefinition()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }

        public QuestionDefinition(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}

			MarkNew();
	    }

	    
	    public QuestionDefinition(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }

    	 
	    public QuestionDefinition(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }

        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("StemId")]
        public Guid StemId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("StemId");
		    }

            set 
		    {
			    SetColumnValue("StemId", value);
            }

        }

	      
        [XmlAttribute("MeasureName")]
        public string MeasureName 
	    {
		    get
		    {
			    return GetColumnValue<string>("MeasureName");
		    }

            set 
		    {
			    SetColumnValue("MeasureName", value);
            }

        }

	      
        [XmlAttribute("MeasureRank")]
        public int? MeasureRank 
	    {
		    get
		    {
			    return GetColumnValue<int?>("MeasureRank");
		    }

            set 
		    {
			    SetColumnValue("MeasureRank", value);
            }

        }

	      
        [XmlAttribute("QuestionText")]
        public string QuestionText 
	    {
		    get
		    {
			    return GetColumnValue<string>("QuestionText");
		    }

            set 
		    {
			    SetColumnValue("QuestionText", value);
            }

        }

	      
        [XmlAttribute("StemRank")]
        public int StemRank 
	    {
		    get
		    {
			    return GetColumnValue<int>("StemRank");
		    }

            set 
		    {
			    SetColumnValue("StemRank", value);
            }

        }

	      
        [XmlAttribute("AnswerType")]
        public string AnswerType 
	    {
		    get
		    {
			    return GetColumnValue<string>("AnswerType");
		    }

            set 
		    {
			    SetColumnValue("AnswerType", value);
            }

        }

	      
        [XmlAttribute("AnswerTypeConfiguration")]
        public string AnswerTypeConfiguration 
	    {
		    get
		    {
			    return GetColumnValue<string>("AnswerTypeConfiguration");
		    }

            set 
		    {
			    SetColumnValue("AnswerTypeConfiguration", value);
            }

        }

	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string StemId = @"StemId";
            
            public static string MeasureName = @"MeasureName";
            
            public static string MeasureRank = @"MeasureRank";
            
            public static string QuestionText = @"QuestionText";
            
            public static string StemRank = @"StemRank";
            
            public static string AnswerType = @"AnswerType";
            
            public static string AnswerTypeConfiguration = @"AnswerTypeConfiguration";
            
	    }

	    #endregion
    }

}

